#ifndef MUSIC_H
#define MUSIC_H

#include <QMainWindow>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QStandardItemModel>
#include <QMediaPlayer>
#include <QMediaPlaylist>
#include <QListWidgetItem>
#include"comment.h"
//#include"mainwindow.h"

namespace Ui {
class music;
}
struct song
{
    char songname[128];   //歌曲名
    char singer[128];     //歌手
    char album_name[128]; //专辑
    int duration2;      //时间
    int music_id;       //音乐id
};
class music : public QWidget
{
    Q_OBJECT

public:
    explicit music(QTcpSocket * clientSocket, QWidget *parent = nullptr);
    ~music();

    music * p1;
public slots:
    void slot_positionChanged(qint64 position);
    void slot_durationChanged(qint64 duration);
    void on_horizontalSlider_sliderReleased();
    void on_pushButton_clicked();
    void replyFinished(QNetworkReply* reply);
    void parseJson(QByteArray jsonByte);
    void on_tableView_doubleClicked(const QModelIndex &index);

    void on_tableView_clicked(const QModelIndex &index);

    void on_listWidget_itemClicked(QListWidgetItem *item);

    void on_listWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
    void pModelclear();
    void onReadyRead();
    void paintEvent(QPaintEvent *event);
private:

    QNetworkAccessManager *manager;

    QMediaPlaylist * playlist;
    QStandardItemModel * pModel;
    QStringList titles;
    QMediaPlayer * player;
public:
    QTcpSocket * clientSocket;
    QList<song> song_List;
//    QList<song> song_List1;
    int currentIndex;
    Ui::music *ui;
    int playmodel=1;//1顺序播放 2随机播放 3单曲循环
private slots:
    void on_pushButton_3_clicked();
    void on_pushButton_2_clicked();
    void on_pushButton_4_clicked();
    void on_comboBox_currentIndexChanged(const QString &arg1);
};

#endif // MUSIC_H
